package NewCode;

/**
 * @author wangchenghao
 * @date 2021/7/22
 **/
public class NC83 {
    public double maxProduct(double[] arr) {
        if (arr==null){
            return 0;
        }else if (arr.length==1){
            return arr[0];
        }

        Double dp[]=new Double[arr.length];
        dp[0]=arr[0];
        for (int i = 1; i < arr.length; i++) {
            Double a=dp[i-1];
            Double b=dp[i-1]*arr[i];
            Double c=arr[i];
            if (a>=b&&a>=c){
                dp[i]=a;
            }else if (b>=a&&b>=a){
                dp[i]=b;
            }else if(c>=a&&c>=b){
                dp[i]=c;
            }
        }
        return dp[arr.length-1];
    }
}
